angular.module('robotGroup', [])

    .config(function RobotGroupRoutes($stateProvider) {
        $stateProvider

            .state('robotGroupDetail', {//路由名称
                parent: 'admin',
                url: '/groupDetail/{groupId:string}',//url以及参数定义
                views: {
                    'main@admin': {
                        templateUrl: 'admin/group/detail.html',//html地址
                        controller: 'RobotGroupController as vm',//控制器和他的别名
                        resolve: {
                            groupRobotList: function(RobotGroup, $stateParams) {
                                return RobotGroup.detail({
                                    groupId: $stateParams.groupId,
                                })
                            }
                        }
                    }
                }
            })
            .state('addRobotInGroup',{
                url: '/addRobotInGroup/:groupId',
                controller: 'AddRobotInGroupController as vm',//控制器和他的别名
                templateUrl: 'admin/group/addRobotInGroup.html',
                resolve: {
                    validAdmin: function ($state,store) {
                        if(_.isNull(store.get('currentAdmin'))){
                            $state.go('session.signin')
                        }
                    }
                }
            })
    })

    .service('RobotGroup', RobotGroupModel)//声明

    .controller('RobotGroupController', RobotGroupController)

    .controller('AddRobotInGroupController',AddRobotInGroupController)

    //弹出框组件
    .controller('deleteRobotIdCtrl', function ($scope, $uibModalInstance) {

        $scope.ok = function () {
            $uibModalInstance.close('ok');
        };
        $scope.cancel = function () {
            $uibModalInstance.close('cancel');
        };
    })

    //弹出框组件
    .controller('robotGroupTipsCtrl', function ($scope, $uibModalInstance) {
        $scope.resultMsg = $scope.data.msg;
        $scope.ok = function () {
            $uibModalInstance.close('ok');
        };
    })


    //弹出框组件
    .controller('showAllRobotCtr', function (Robot , RobotGroup, $scope, $uibModalInstance) {


    });
